<html>
<head><meta charset="utf-8"><title>stacked borrows: retag on drop shims · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked.20borrows.3A.20retag.20on.20drop.20shims.html">stacked borrows: retag on drop shims</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="159059944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked%20borrows%3A%20retag%20on%20drop%20shims/near/159059944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked.20borrows.3A.20retag.20on.20drop.20shims.html#159059944">(Feb 21 2019 at 11:26)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> </p>
<blockquote>
<p>The automatically generated drop shims perform a <code>Raw</code> retag of their argument because they use it as a raw pointer.</p>
</blockquote>
<p>Does this also applies for <code>Drop::drop(&amp;mut self)</code> ? Or why does this behave differently ?</p>



<a name="159061790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked%20borrows%3A%20retag%20on%20drop%20shims/near/159061790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked.20borrows.3A.20retag.20on.20drop.20shims.html#159061790">(Feb 21 2019 at 11:59)</a>:</h4>
<p><code>Drop::drop</code> is not the automatically generated drop shim</p>



<a name="159061793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked%20borrows%3A%20retag%20on%20drop%20shims/near/159061793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked.20borrows.3A.20retag.20on.20drop.20shims.html#159061793">(Feb 21 2019 at 11:59)</a>:</h4>
<p>that would be <code>ptr::real_drop_in_place</code> nowadays</p>



<a name="159061986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked%20borrows%3A%20retag%20on%20drop%20shims/near/159061986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked.20borrows.3A.20retag.20on.20drop.20shims.html#159061986">(Feb 21 2019 at 12:03)</a>:</h4>
<p>Is the automatically generated drop shim called at the end / after <code>Drop::drop</code> for <code>Drop</code> types?  I don't know how this works.</p>



<a name="159062121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked%20borrows%3A%20retag%20on%20drop%20shims/near/159062121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked.20borrows.3A.20retag.20on.20drop.20shims.html#159062121">(Feb 21 2019 at 12:06)</a>:</h4>
<p>the drop shim calls <code>Drop::drop</code></p>



<a name="159062129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked%20borrows%3A%20retag%20on%20drop%20shims/near/159062129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked.20borrows.3A.20retag.20on.20drop.20shims.html#159062129">(Feb 21 2019 at 12:06)</a>:</h4>
<p>Ah ok!</p>



<a name="159062130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked%20borrows%3A%20retag%20on%20drop%20shims/near/159062130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stacked.20borrows.3A.20retag.20on.20drop.20shims.html#159062130">(Feb 21 2019 at 12:06)</a>:</h4>
<p>and then proceeds to recursively call the drop shim for the fields</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>